package com.zy.algorithm.v3

import com.zy.activity.BaseMainActivity
import android.os.Bundle
import android.content.pm.ActivityInfo
import androidx.fragment.app.Fragment

class AlgorithmV3MainActivity : BaseMainActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //设置横屏
        requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
    }

    override val containerFragment: Fragment?
        protected get() {

            val code = intent.getIntExtra("code", 0)

            val targetClass = intent.getSerializableExtra("targetClass") as Class<*>?
            var fragment: Fragment? = null
            if (targetClass != null) {
                try {
                    fragment = targetClass.newInstance() as Fragment
                } catch (e: IllegalAccessException) {
                    e.printStackTrace()
                } catch (e: InstantiationException) {
                    e.printStackTrace()
                }
            }
            fragment?.arguments = intent.extras

            return fragment
        }
}